package day6;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * @author oldliu
 * @since 1.0
 */
public class FileRead4 {
    public static void main(String[] args) {
        InputStream in = null;
        try {
            in = new FileInputStream("F:\\java82\\zhangliangmu\\作业.txt");
            byte b[]=new byte[20];//字符被截取部分的情况，导致乱码
            int len=0;
            while ((len=in.read(b))>-1){
//                //输出字节
////                for (int i =0; i <len ; i++) {
////                    System.out.print(b[i]+" ");
////                }
                //转换成字符
                String str=new String(b,0,len);
                System.out.println(str);
                System.out.println();
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (in != null)
                    in.close();
            } catch (IOException e) {

            }
        }
    }
}
